package 时间API;

import org.junit.Test;

import java.time.Duration;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

/**
 * Description
 *
 * @Author: SunAo
 * @Date: 2022/3/30 17:37
 */
public class 时间间隔计算Duration {

    @Test
    public void 两个时间之间的间隔(){
        LocalDateTime time1 = LocalDateTime.of(2022,10,1,10,9,00);
        LocalDateTime time2 = LocalDateTime.of(2022,10,1,10,8,00);
        Duration duration = Duration.between(time1,time2);
        System.out.println(duration.get(ChronoUnit.SECONDS));
    }

    @Test
    public void 毫秒值相差(){
        LocalDateTime time1 = LocalDateTime.of(2022,10,1,10,7,00);
        LocalDateTime time2 = LocalDateTime.of(2022,10,1,10,8,00);
        Duration duration = Duration.between(time1,time2);
        System.out.println(duration.get(ChronoUnit.SECONDS) * 1000);
    }

    @Test
    public void sss(){
        Long ss = 0L;
        System.out.println(ss == 0);
    }
}

